package com.open.launcher.activity.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.open.launcher.R;
import com.open.launcher.base.BaseRecycleViewAdapter;

import java.util.List;

/**
 * Created by Administrator on 2018/4/11.
 */

public class LiveFirstAdapater extends BaseRecycleViewAdapter<LiveFirstAdapater.ViewHolder> {
    List<String> liveTypeList;
    public LiveFirstAdapater(Context context) {
        mContext = context;

    }

    public List<String> getLiveTypeList() {
        return liveTypeList;
    }

    public void setLiveTypeList(List<String> liveTypeList) {
        this.liveTypeList = liveTypeList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_allchannels_view, null, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }


    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
        if (position==0){
            holder.tvName.setBackgroundResource(R.mipmap.dise_left);
        }
        holder.tvName.setText(liveTypeList.get(position));
        holder.itemView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean b) {
                if (focusChangelistener!=null){
                    focusChangelistener.onItemFoucus(view,b);
                }
            }
        });
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onItemClick(v, position);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        if (liveTypeList==null){
            return 1;
        }else {
            return liveTypeList.size();
        }
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvName;

        public ViewHolder(View view) {
            super(view);
            tvName = view.findViewById(R.id.mainchanel_text);
        }
    }
}
